<%@ page import="com.psl.model.halfproduct_kc" %>
<%@ page import="com.psl.model.userlogin" %>
<%@ page import="com.psl.services.work.halfproductkc" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    userlogin userinfo = (userlogin) session.getAttribute("user");
    if (userinfo == null) {
        response.sendRedirect("/login.do");
    }
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="/assets/css/text.css" rel="stylesheet" type="text/css">
    <link href="/assets/css/main.css" rel="stylesheet" type="text/css">
    <link href="/assets/css/content.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" type="text/JavaScript">
    </script>
    <style>
        #title {
            width: 92%;
            border: 0px;
            margin-bottom: 10px;
        }

        #title td {
            text-align: center;
            height: 20px;
            line-height: 150%
        }

        #title div {
            background-image: url(/assets/img/dot_02.gif);
            background-position: left top;
            background-repeat: no-repeat;
            margin: 0 auto;
            padding-left: 20px;
            text-align: left;
            width: 10%;
            font-size: 15px;
            font-weight: bold;
            color: #CC0000;
            letter-spacing: 2px;
        }

        tr.change:hover {
            background-color: #dd3c10;
        }
    </style>

</head>
<body>
<table cellspacing="0" cellpadding="0" id="title" align="center">
    <tbody>
    <tr>
        <td nowrap="nowrap">
            <div>山东宜利达流体设备有限公司铸件/配件库存表</div>
        </td>
    </tr>
    </tbody>
</table>
<table cellpadding="0" cellspacing="0" class="datalist" align="center">
    <tr>
        <th colspan="1">编号</th>
        <th colspan="1">名称</th>
        <th colspan="1">规格</th>
        <th colspan="1">操作</th>
    </tr>
    <form action="/gethname7.do" method="post">
        <tr>
            <td align="center" colspan="1"></td>
            <td align="center" colspan="1"><input name="h_name" type="text" value=""></td>
            <td align="center" colspan="1"><input name="h_size" type="text" value=""></td>
            <td align="center" colspan="1"><input type="submit" value="查询"/></td>
        </tr>
    </form>
    <c:if test="${not empty query}">
        <c:forEach items="${query}" var="q" varStatus="status">
            <script>
                function add${status.count}() {
                    document.getElementById("h_no").value = document.form${status.count}.no.value;
                    document.getElementById("h_name").value = document.form${status.count}.name.value;
                    document.getElementById("h_size").value = document.form${status.count}.size.value;
                }
            </script>
            <form name="form${status.count}">
                <tr class="change">
                    <td align="center" colspan="1"><input type="hidden" id="no${status.count}" name="no"
                                                          value="${q.h_no}"/> ${q.h_no}</td>
                    <td align="center" colspan="1"><input type="hidden" id="name${status.count}" name="name"
                                                          value="${q.h_name}"/>${q.h_name}</td>
                    <td align="center" colspan="1"><input type="hidden" id="size${status.count}" name="size"
                                                          value="${q.h_size}"/>${q.h_size}</td>
                    <td align="center" colspan="1"><input type="button" value="添加" onclick="add${status.count}()"/></td>
                </tr>
            </form>
        </c:forEach>
    </c:if>
    </tbody>
</table>


<table border="0" align="center" cellpadding="0" cellspacing="0" class="datalist">
    <tbody>
    <tr>
    <td colspan="9" height="9" ><input type="button" value="打印" class="nobtn"
                                                     onclick="window.print();"></td></tr>

    </tr>
   <tr><td height="40" colspan="9"></td></tr>
    <tr>
        <th align="center" >铸件/配件编号 <a href="/list/halfproduct/halfsearchpage.jsp">点我查询</a> </th>
        <th height="25" align="center" >铸件/配件名称</th>
        <th align="center" >规格</th>
        <th align="center" >商标</th>
        <th align="center" >压力</th>
        <th align="center" >原有库存数量 &nbsp; &nbsp;<%if(userinfo.getPosition_id()==1){%><a href="/reback.do">一键清除所有数据</a><%}%> </th>
        <th align="center" >入库数量</th>
        <th align="center" >出库数量</th>
        <th align="center" >结存数量</th>
    </tr>
    <%if(userinfo.getPosition_id()==1||userinfo.getPosition_id()==4||userinfo.getPosition_id()==7){%>
    <form action="/insertkc.do" method="post">
    <tr>
        <td align="center"  colspan="1"><input name="h_no" id="h_no" type="text" value=""></td>
        <td align="center"  colspan="1"><input name="h_name" id="h_name" type="text" value=""></td>
        <td align="center"  colspan="1"><input name="h_size" id="h_size" type="text" value=""></td>
        <td align="center"  colspan="1"><jsp:include page="R.jsp"/></td>
        <td align="center"  colspan="1"><jsp:include page="PN.jsp"/></td>
        <td align="center"  colspan="1"><input name="h_num_old" type="text" value=""></td>
        <td align="center"  colspan="1"></td>
        <td align="center"  colspan="1"></td>
        <td align="center"  colspan="1"><input type="submit" value="保存"></td>
    </tr>
    </form>
    <tr><td height="30" colspan="9"></td></tr>
    <%}%>
    <%
        halfproductkc hps = new halfproductkc();
        List hp = hps.queryAllkc();
        Iterator iter = hp.iterator();
        halfproduct_kc kc = null;
        int i = 1;
        while (iter.hasNext()) {
            i = i + 1;
            kc = (halfproduct_kc) iter.next();
    %>
    <tr>
        <td height="25" align="center" ><%=kc.getH_no()%>
        </td>
        <td height="25" align="center" ><%=kc.getH_name()%>
        </td>
        <td height="25" align="center" ><%=kc.getH_size()%>
        </td>
        <td height="25" align="center" ><%=kc.getH_r()%>
        </td>
        <td height="25" align="center" ><%=kc.getH_n()%>
        </td>
        <td height="25" align="center" >
            <%if(userinfo.getPosition_id()==1||userinfo.getPosition_id()==7){%>
            <form name="form<%=i%>" action="/update_num_old.do" method="post">
                <input type="hidden" name="h_no" value="<%=kc.getH_no()%>">
                <input type="hidden" name="h_size" value="<%=kc.getH_size()%>">
                <input type="hidden" name="h_r" value="<%=kc.getH_r()%>">
                <input type="hidden" name="h_n" value="<%=kc.getH_n()%>">
                <input name="h_num_old" type="text" value="<%=kc.getH_num_old()%>">
                <input type="submit" value="保存">
            </form>
            <%}else {%><%=kc.getH_num_old()%><%}%>
        </td>
        <td height="25" align="center" ><%=kc.getH_num()%></td>
        <td height="25" align="center" >
            <%if(userinfo.getPosition_id()==1||userinfo.getPosition_id()==7){%>
            <form name="form<%=i%>" action="/update_num_now.do" method="post">
                <input type="hidden" name="h_no" value="<%=kc.getH_no()%>">
                <input type="hidden" name="h_size" value="<%=kc.getH_size()%>">
                <input type="hidden" name="h_r" value="<%=kc.getH_r()%>">
                <input type="hidden" name="h_n" value="<%=kc.getH_n()%>">
                <input name="h_num" type="hidden" value="<%=kc.getH_num()%>">
                <input name="h_num_old" type="hidden" value="<%=kc.getH_num_old()%>">
                <input name="h_num_out" type="text" value="0"/>
                <input type="submit" value="保存">
            </form>
            <%}else {%>无修改权限<%}%>
        </td>
        <td height="25" align="center" ><%if(kc.getH_num_now()<30){out.print("<span style='color: red'>"+kc.getH_num_now()+"</span>");}else {%><%=kc.getH_num_now()%><%}%>
        </td>
    </tr>
    <%}%>
    </tbody>
</table>

</body>
</html>